<!--#include file="Ini.asp"-->
<!--#include file="../AspLib/Functions.asp"-->

<%

sESCOLA = Request.QueryString("ESCOLA") 


Response.expires = 0
MSQL="SELECT * FROM PNLD_2005_MUN_ESC_LIVRO "
MSQL=MSQL & " WHERE CODESC='"& SESCOLA &"' ORDER BY EDITORA,TITULO,SERIE"
Set Conn = Server.CreateObject("ADODB.Connection")
conn.CommandTimeout = 1500
Conn.Open sCo1, sCo2, sCo3
Set rs = Conn.Execute(MSql)			 
'response.write msql
'response.end
IF RS.EOF THEN
  RESPONSE.END
END IF

%>
<html>
<head>
<title><% = sTitle %></title>
<% = sBODY %>
<% = sCABECALHO %>VENDAS PNLD 2005 <% = sFONT %></b>
<BR><% = RS("NOME") %>
<table width='100%' border='1'<% =  sTABLE %>>
<tr bgcolor='<% = COR_TARJA %>'>
  <td align='right'>S</td>
  <td>Livro</td>
  <td align='right'>Qtd.</td>
  </tr><%
  mcnt=0
  GQTD=0
  GVAL=0
  mcnte=0
  GQTDE=0
  GVALE=0
  

 Do while not rs.eof
  mcnte=0
  GQTDE=0
  GVALE=0
  medi=rs("EDITORA")
  medif=rs("EDITORA")
 Do while not rs.eof and medi=medif
 
    mcnt=mcnt+1
    GQTD=GQTD+rs("QTD")
    GVAL=GVAL+rs("VALOR")
    mcntE=mcntE+1
    GQTDE=GQTDE+rs("QTD")
    GVALE=GVALE+rs("VALOR")
    IF rs("QTD")=0 THEN
     MQTD=1
     MVVV=1
    ELSE
     MQTD=rs("QTD")
     MVVV=rs("VALOR")
    END IF
    %><TR>
     <td>&nbsp;<% = rs("SERIE") %></td>
     <td>&nbsp;<% = mid(rs("TITULO"),1,33) %></td>
    <td align='right'><% = FORMATNUMBER(rs("QTD"),0) %></td>
    </tr><%
    rs.MoveNext  
    if not rs.eof then
      medif=rs("EDITORA")
    else
      medif="zzzzzz"
    end if   	
  loop
	  %><tr>
	  <td colspan='2'><B>Editora (<% =medi %>) <% = MCNTE %> ITENS<br></td>
	  <td align='right'><B><% = FORMATNUMBER(GQTDE,0)  %></td>
   </tr><%
  loop

	  %><tr>
	  <td colspan='2'><B>Escola <% = MCNT %> ITENS<br></td>
	  <td align='right'><B><% = FORMATNUMBER(GQTD,0)  %></td>
   </tr><%

rs.Close : Set rs = Nothing
Conn.Close : Set conn = Nothing 
%>
